import "package:flutter/material.dart";
import 'package:shortmovieapp/common.dart';
import 'package:shortmovieapp/data/viewData.dart';
import 'package:shortmovieapp/data/localData.dart';
import 'package:shortmovieapp/myPages/myHomePage.dart';
import 'shareView.dart';

class favioritesPage extends StatefulWidget {
  //final Function()? onClickFindMovie;
  final List<MovieItemData>? movieItemsData;

  const favioritesPage({super.key, this.movieItemsData});//, this.onClickFindMovie

  @override
  State<favioritesPage> createState() => _favioritesPageState();
}

class _favioritesPageState extends State<favioritesPage> {
  @override
  void initState() {
    Debug.log("faviours:${widget.movieItemsData?.length}");

    super.initState();
  }

  @override
  Widget build(BuildContext context) {
 
    if (widget.movieItemsData != null) {
      return Container(
          padding: const EdgeInsets.fromLTRB(10, 40, 10, 0),
          alignment: Alignment.center,
          child: MovieItemsGrid(itemDatas: widget.movieItemsData!));
    } else {
      return Container(
        alignment: Alignment.center,
        child: SizedBox(
          width: 200,
          height: 350,
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
           // crossAxisAlignment: CrossAxisAlignment.end,
          children: [
            const CircleAvatar(
                radius: 30,
                backgroundImage: NetworkImage(
                    "https://www.itying.com/images/flutter/3.png")),
            const SizedBox(height: 10),
            const Text("暂无收藏短剧"),
            const SizedBox(height: 10),
            SizedBox(
              width:100,
              height:40,
              child:ElevatedButton(
              
              style: ButtonStyle(
              
                backgroundColor: MaterialStateProperty.all<Color>(
                  Colors.orange),
                   // const Color.fromARGB(1, 255, 68, 0)), // 背景颜色
                foregroundColor:
                    MaterialStateProperty.all<Color>(Colors.white), // 文字颜色
                padding: MaterialStateProperty.all<EdgeInsetsGeometry>(
                    const EdgeInsets.fromLTRB(20, 5, 20, 5)), // 内边距
                shape: MaterialStateProperty.all<OutlinedBorder>(
                  RoundedRectangleBorder(
                    borderRadius: BorderRadius.circular(16), // 圆角
                  ),
                ),
              ),
              onPressed: () {
                Debug.log("on pressed find movie");
                
              var parentState = context.findAncestorStateOfType<myHomePageState>()!;
              parentState.setToPage(MyPageTag.recommended);
                //widget.onClickFindMovie?.call();
              },
              child:const Text("找短剧") ,
            )
            )
          ]),
        ),
      );
    }
  }
}
